/*** Eclipse Class Decompiler plugin, copyright (c) 2012 Chao Chen (cnfree2000@hotmail.com) ***/
package com.qihoopp.qcoinpay;

import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public final class cv {
    private String a = "AES/ECB/PKCS5Padding";
    private SecretKey b;
    private Cipher c;
    private IvParameterSpec d;

    public cv(String paramString1, String paramString2, String paramString3) {
        byte[] arrayOfByte1 = new byte[16];
        byte[] arrayOfByte2 = new byte[16];
        this.a = paramString3;
        this.c = Cipher.getInstance(paramString3);
        KeyGenerator.getInstance("AES").init(128);
        int i;
        if (paramString1 != null) {
            paramString1 = paramString1.getBytes();
            for (i = 0; (i < paramString1.length) && (i < arrayOfByte1.length); ++i)
                arrayOfByte1[i] = paramString1[i];
        }
        this.b = new SecretKeySpec(arrayOfByte1, "AES");
        if (paramString3.indexOf("ECB") != -1)
            return;
        if (paramString2 != null) {
            paramString1 = paramString2.getBytes();
            for (i = 0; (i < paramString1.length) && (i < arrayOfByte2.length); ++i)
                arrayOfByte2[i] = paramString1[i];
        }
        this.d = new IvParameterSpec(arrayOfByte2);
    }

    public final byte[] a(String paramString) {
        try {
            if (this.a.indexOf("ECB") == -1)
                this.c.init(1, this.b, this.d);
            else
                this.c.init(1, this.b);
            paramString = this.c.doFinal(paramString.getBytes());
        } catch (Exception localException) {
            localException.printStackTrace();
            return null;
        }
        return paramString;
    }
}